
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>非核心线程能成为核心线程吗？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>非核心线程能成为核心线程吗？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">在Java线程池中，核心线程与非核心线程的主要区别是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">核心线程是线程池中长期存在的线程，即使没有任务也会保持活跃。非核心线程是当任务量超过核心线程处理能力时创建的临时线程，在空闲一段时间后会被回收终止。</div>
          </div>
          <div class="card-source">来源: 1. 核心线程（Core Threads） 和 2. 非核心线程（Non-Core Threads）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">描述一下Java线程池中核心线程（Core Threads）的三个主要特点。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">核心线程的三个主要特点是：1. 持续存在，即使空闲也不会被回收（除非线程池关闭）；2. 在线程池创建时就会被初始化；3. 通常优先于非核心线程处理任务。</div>
          </div>
          <div class="card-source">来源: 1. 核心线程（Core Threads）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">什么条件下，Java线程池会创建非核心线程？它们的生命周期是如何管理的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当线程池中的线程数超过核心线程数（corePoolSize）时，会创建非核心线程来处理更多任务。它们的生命周期由`keepAliveTime`参数管理，如果一个非核心线程的闲置时间超过这个值，它就会被终止。</div>
          </div>
          <div class="card-source">来源: 2. 非核心线程（Non-Core Threads）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">在默认的线程池配置下，非核心线程能否自动转变为核心线程？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">不能。在默认的线程池配置中，非核心线程无法直接或自动转换为核心线程。它们的职责和生命周期管理是分开的。</div>
          </div>
          <div class="card-source">来源: 线程从非核心变成核心的情境</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">如果需要动态增加一个已在运行的线程池的核心线程数量，应该使用什么方法？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">可以通过调用 `ThreadPoolExecutor` 实例的 `setCorePoolSize(newCorePoolSize)` 方法来动态调整线程池的核心线程数。</div>
          </div>
          <div class="card-source">来源: 线程从非核心变成核心的情境</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">控制非核心线程空闲存活时间的参数是什么？其作用机制是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">控制非核心线程空闲存活时间的参数是 `keepAliveTime`。其作用机制是：当非核心线程的空闲时间超过 `keepAliveTime` 设定的时长后，该线程就会被终止并回收。</div>
          </div>
          <div class="card-source">来源: 2. 非核心线程（Non-Core Threads）</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
